package suites.stub {
	import flash.events.TimerEvent;

	import org.splink.library.queue.Qable;

	import flash.utils.Timer;

	/**
	 * @author Max Kugland
	 */
	public class RequestShowStrategyStub extends Qable {
		private var _history : Array;
		private var _timer : Timer;

		public function RequestShowStrategyStub(id : String, history : Array, async : Boolean = false) {
			super(id);
			_history = history;
			if(async) _timer = new Timer(10, 1);
		}

		override protected function doStart() : void {
			if(_timer) {
				_timer.addEventListener(TimerEvent.TIMER_COMPLETE, function(e : TimerEvent) : void {
					_timer.removeEventListener(TimerEvent.TIMER_COMPLETE, arguments["callee"]);
					done();
				});
				_timer.start();
			} else {
				done();
			}
		}

		private function done() : void {
			_history.push("show-" + id);
			complete();
		}
	}
}
